package com.vito.dcs.asphalt.pore.action;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.dubbo.config.annotation.Reference;
import com.vito.base.authoriza.action.BaseAction;
import com.vito.base.exception.ParamErrorException;
import com.vito.base.model.ResMsg;
import com.vito.base.model.Result;
import com.vito.base.util.Validata;
import com.vito.dcs.asphalt.pore.model.MixAsphaltPoreModel;
import com.vito.dcs.asphalt.pore.service.MixAsphaltPoreService;

/**
 * 沥青搅拌机设备设置筛孔表请求控制器
 * @author  lyhao E-mail: 
 * @version 0.0.1
 * @date    2019-4-15 11:06:32
 */
@Controller
@RequestMapping("/dcs/asphalt/pore")
public class MixAsphaltPoreAction extends BaseAction {
	
	private static final Logger log = LoggerFactory.getLogger(MixAsphaltPoreAction.class);
	
	@Reference
	private MixAsphaltPoreService mixasphaltporeServiceImpl;
	
	/**
	 * 保存沥青搅拌机设备设置筛孔表
	 * @author  lyhao E-mail: 
	 * @version 创建时间：2019-4-15 11:06:32
	 * @return  code:状态码 ,msg:提示信息
	 * @param   mixasphaltpore 需要保存的沥青搅拌机设备设置筛孔表对象
	*			3434
	 *		 	<li>BlenderId:沥青搅拌机ID 不能为null 或空字符串</li>
	 */
	@RequestMapping("saveMixAsphaltPore")
	@ResponseBody
	public Result saveMixAsphaltPore(@RequestBody MixAsphaltPoreModel mixasphaltpore){
		Result res = new Result();
		try{
			Validata.isNullOrEmpty(mixasphaltpore, "沥青搅拌机设备设置筛孔表不能为空");
			Validata.isNullOrEmpty(mixasphaltpore.getBlenderId(), "沥青搅拌机ID不能为空");
			mixasphaltporeServiceImpl.saveMixAsphaltPore(mixasphaltpore);
			res.setCode(Result.CODE_OK);
			res.setMsg(ResMsg.SAVESUC);
		}catch(ParamErrorException e){
			res.setMsg(e.getMessage());
			res.setCode(Result.CODE_ERROR);
		}catch(Exception ex){
			log.error("保存失败",ex);
			res.setCode(Result.CODE_ERROR);
			res.setMsg(ResMsg.EXECERR);
		}
		return res;
	}
	
	/**
	 * 分页查询沥青搅拌机设备设置筛孔表
	 * @author  lyhao E-mail: 
	 * @version 创建时间：2019-4-15 11:06:32
	 * @return  {code:0,data:{total:20,rows:[{}...]}}
	 * @param   mixasphaltpore 依靠沥青搅拌机设备设置筛孔表对象分页查询
	 *          <li>pageNo default 1</li>
	 *          <li>pageSize default 15</li>
	 */
	@RequestMapping("queryMixAsphaltPoreByPage")
	@ResponseBody
	public Result queryMixAsphaltPoreByPage(MixAsphaltPoreModel mixasphaltpore){
		Result res = new Result();
		try{
			Validata.isNullOrEmpty(mixasphaltpore, "沥青搅拌机设备设置筛孔表不能为空");
			res.setData(mixasphaltporeServiceImpl.queryMixAsphaltPoreByPage(mixasphaltpore));
			res.setCode(Result.CODE_OK);
		}catch(ParamErrorException e){
			res.setMsg(e.getMessage());
			res.setCode(Result.CODE_ERROR);
		}catch(Exception ex){
			log.error("查询失败",ex);
			res.setCode(Result.CODE_ERROR);
			res.setMsg(ResMsg.EXECERR);
		}
		return res;
	}
	
	/**
	 * 查询一条沥青搅拌机设备设置筛孔表
	 * @author  lyhao E-mail: 
	 * @version 创建时间：2019-4-15 11:06:32
	 * @return  {code:0,data:{...}}
	 * @param   mixasphaltpore 依靠沥青搅拌机设备设置筛孔表对象查询
	 */
	@RequestMapping("queryMixAsphaltPore")
	@ResponseBody
	public Result queryMixAsphaltPore(MixAsphaltPoreModel mixasphaltpore){
		Result res = new Result();
		try{
			res.setData(mixasphaltporeServiceImpl.queryMixAsphaltPore(mixasphaltpore));
			res.setCode(Result.CODE_OK);
		}catch(Exception ex){
			log.error("查询失败",ex);
			res.setCode(Result.CODE_ERROR);
			res.setMsg(ResMsg.EXECERR);
		}
		return res;
	}
		
	/**
	 * 更新沥青搅拌机设备设置筛孔表对象
	 * @author  lyhao E-mail: 
	 * @version 创建时间：2019-4-15 11:06:32
	 * @return  {code:0,data:10}
	 * @param   mixasphaltpore 依靠沥青搅拌机设备设置筛孔表对象的id变更传入的其他属性值
	 *		 	<li>Id:主键ID 不能为null 或空字符串</li>
	 *		 	<li>BlenderId:沥青搅拌机ID 不能为null 或空字符串</li>
	 */
	@RequestMapping("updateMixAsphaltPore")
	@ResponseBody
	public Result updateMixAsphaltPore(@RequestParam Map<String,Object> map){
		Result res = new Result();
		try{
			mixasphaltporeServiceImpl.updateMixAsphaltPore(map);
			res.setCode(Result.CODE_OK);
			res.setMsg(ResMsg.UPDSUC);
		}catch(Exception ex){
			log.error("更新失败",ex);
			res.setCode(Result.CODE_ERROR);
			res.setMsg(ResMsg.EXECERR);
		}
		return res;
	}
	
	@RequestMapping("queryMixAsphaltPoreByBlenderId")
	@ResponseBody
	public Result queryMixAsphaltPoreByBlenderId(@RequestParam Map<String,Object> map){
		Result rs = new Result();
		try{
			rs.setData(mixasphaltporeServiceImpl.queryMixAsphaltPoreByBlenderId(map));
			rs.setCode(Result.CODE_OK);
		}catch(Exception ex){
			log.error("查询失败",ex);
			rs.setCode(Result.CODE_ERROR);
			rs.setMsg(ResMsg.EXECERR);
		}
		return rs;
	}
}



